package com.example.makerspace.controller.personRecommend;
import com.example.makerspace.dto.PageRequest;
import com.example.makerspace.dto.PersonalRecommendationsDTO;
import com.example.makerspace.dto.Result;
import com.example.makerspace.service.PersonalRecommendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@ResponseBody
@RequestMapping("/api/personalRecommend")
@Api(tags = "个性推荐模板")
public class PersonalRecommendController {
    @Resource
    private PersonalRecommendService personalRecommendService;


    @ApiOperation(value="个性化推荐初始化接口",notes ="个性化推荐初始化接口说明")
    @GetMapping("/init")
    public Result init(@RequestParam("username") String username){
        return  personalRecommendService.init(username);
    }
    @ApiOperation(value="用户停留时间-个性化推荐接口",notes ="用户停留时间-个性化推荐接口说明")
    @PostMapping("/userStay")
    public Result userStay(@RequestBody PersonalRecommendationsDTO personalRecommendationsDTO){
        return  personalRecommendService.userStay(personalRecommendationsDTO);
    }
    @ApiOperation(value="个性化推荐更新接口",notes ="个性化推荐更新接口说明")
    @PostMapping("/updatePersonalRecommend")
    public Result updatePersonalRecommend(@RequestBody PersonalRecommendationsDTO personalRecommendationsDTO){
        return  personalRecommendService.updatePersonalRecommend(personalRecommendationsDTO);
    }

    @ApiOperation(value="获取产品列表-通过打分接口",notes ="获取产品列表-通过打分接口说明")
    @PostMapping("/showProductBySort")
    public Result showProductBySort(@RequestBody PageRequest pageReques){
        return  personalRecommendService.showProductBySort(pageReques);
    }





}
